package demo1;

/**
 * Created with IntelliJ IDEA.
 * User: 12629
 * Date: 2021/10/27
 * Time: 11:38
 * Description:
 */
class Shape {
    public void draw() {

    }
}
class Cycle extends Shape{
    @Override
    public void draw() {
        System.out.println("●");
    }
}

class Rect extends Shape{
    @Override
    public void draw() {
        System.out.println("♦");
    }
}
class Flower extends Shape {
    @Override
    public void draw() {
        System.out.println("❀");
    }
}


public class TestExample {

    public static void drawMap(Shape shape) {
        shape.draw();
    }


    public static void drawShapes1() {
        Rect rect = new Rect();
        Cycle cycle = new Cycle();

        String[] shapes = {"1", "rect", "1", "rect"};
        for (String shape : shapes) {
            if (shape.equals("1")) {
                cycle.draw();
            } else if (shape.equals("rect")) {
                rect.draw();
            }
        }
    }

    public static void drawShapes() {
        // 我们创建了一个 Shape 对象的数组.
        Shape shapepp = new Cycle();
        Shape[] shapes = {new Cycle(), new Rect(),
                new Cycle(),new Rect(),new Flower()};
        for (Shape shape : shapes) {
            shape.draw();
        }
    }
    public static void main(String[] args) {
        drawShapes();
    }

    public static void main1(String[] args) {
        Cycle cycle = new Cycle();
        Rect rect = new Rect();

        drawMap(cycle);
        drawMap(rect);
    }
}
